package com.mask.sca.core.exception;

/**
 * 业务异常
 */
public class BusinessException extends RuntimeException {
    private final int code;

    // 基于错误码枚举创建
    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    // 自定义错误码和信息
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    // 带Throwable的构造方法（用于包装其他异常）
    public BusinessException(ErrorCode errorCode, Throwable cause) {
        super(errorCode.getMessage(), cause);
        this.code = errorCode.getCode();
    }

    public int getCode() {
        return code;
    }
}